package com.ksd.pug.controller.hotelcomment;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ksd.pug.service.hotelcomment.IHotelCommentService;
import com.ksd.pug.pojo.HotelComment;
import com.ksd.pug.vo.HotelCommentVo;
import com.ksd.pug.commons.enums.ResultStatusEnumA;
import com.ksd.pug.commons.ex.PugValidationException;
import com.ksd.pug.commons.utils.fn.asserts.Vsserts;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import com.ksd.pug.controller.BaseController;
import java.util.List;

/**
 * HotelCommentController
 * 创建人:yykk<br/>
 * 时间：2022-04-18 01:07:39 <br/>
 * 源码下载：前台代码 git clone https://gitee.com/kekesam/kuangstudy-pug-ui.git
 * 飞哥B站地址：后台代码 git clone https://gitee.com/kekesam/kuangstudy-pug-parent.git
 * @version 1.0.0<br/>
 *
*/

@RestController
@RequiredArgsConstructor
@Slf4j
public class HotelCommentController extends BaseController{

    private final IHotelCommentService hotelcommentService;


    /**
     * 查询酒店评论列表信息
     * @path : /admin/hotelcomment/load
     * @method: findHotelComments
     * @result : List<HotelComment>
     * 创建人:yykk
     * 创建时间：2022-04-18 01:07:39
     * @version 1.0.0
     * @return
     */
    @GetMapping("/hotelcomment/load")
    public List<HotelComment> findHotelCommentList() {
        return hotelcommentService.findHotelCommentList();
    }

	/**
	 * 查询酒店评论列表信息并分页
	 * @path : /admin/hotelcomment/list
     * @method: findHotelComments
     * @param : hotelcommentVo
     * @result : IPage<HotelComment>
	 * 创建人:yykk
	 * 创建时间：2022-04-18 01:07:39
	 * @version 1.0.0
	*/
    @PostMapping("/hotelcomment/list")
    public IPage<HotelComment> findHotelComments(@RequestBody HotelCommentVo hotelcommentVo) {
        return hotelcommentService.findHotelCommentPage(hotelcommentVo);
    }


    /**
     * 根据酒店评论id查询明细信息
     * @method: get/{id}
     * @path : /admin/hotelcomment/get/{id}
     * @param : id
     * @result : HotelComment
     * 创建人:yykk
     * 创建时间：2022-04-18 01:07:39
     * @version 1.0.0
    */
    @GetMapping("/hotelcomment/get/{id}")
    public HotelComment getHotelCommentById(@PathVariable("id") String id) {
        if(Vsserts.isEmpty(id)){
           throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return hotelcommentService.getHotelCommentById(new Long(id));
    }


	/**
	 * 保存和修改酒店评论
     * @method: saveupdate
	 * @path : /admin/hotelcomment/save
     * @param : hotelcomment
     * @result : HotelComment
	 * 创建人:yykk
	 * 创建时间：2022-04-18 01:07:39
	 * @version 1.0.0
	*/
    @PostMapping("/hotelcomment/saveupdate")
    public HotelComment saveupdateHotelComment(@RequestBody HotelComment hotelcomment) {
        return hotelcommentService.saveupdateHotelComment(hotelcomment);
    }


    /**
	 * 根据酒店评论id删除酒店评论
     * @method: delete/{id}
     * @path : /admin/hotelcomment/delete/{id}
     * @param : id
     * @result : int
	 * 创建人:yykk
	 * 创建时间：2022-04-18 01:07:39
	 * @version 1.0.0
	*/
    @PostMapping("/hotelcomment/delete/{id}")
    public int deleteHotelCommentById(@PathVariable("id") String id) {
        if(Vsserts.isEmpty(id)){
            throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return hotelcommentService.deleteHotelCommentById(new Long(id));
    }


   /**
   	 * 根据酒店评论ids批量删除酒店评论
     * @method: hotelcomment/delBatch
     * @path : /admin/hotelcomment/delBatch
     * @param : hotelcommentVo
     * @result : boolean
   	 * 创建人:yykk
   	 * 创建时间：2022-04-18 01:07:39
   	 * @version 1.0.0
   	*/
    @PostMapping("/hotelcomment/delBatch")
    public boolean delHotelComment(@RequestBody HotelCommentVo hotelcommentVo) {
        log.info("你要批量删除的IDS是:{}", hotelcommentVo.getBatchIds());
        if (Vsserts.isEmpty(hotelcommentVo.getBatchIds())) {
            throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return hotelcommentService.delBatchHotelComment(hotelcommentVo.getBatchIds());
    }

}